<template>
	<view class="wish-view">
		<view class="search-view">
			<u-search :placeholder="$t('searchResult.search')" :showAction="false" @click="goSearch" :disabled="true" height="37">
			</u-search>
		</view>

		<u-list @scrolltolower="scrolltolower">
			<u-list-item>
				<view class="goods-list">
					<GoodsItem :isShinee="true" :goodsItem="item" v-for="(item, index) in wishGoodsList" :key="index"></GoodsItem>
				</view>
			</u-list-item>
		</u-list>
	</view>
</template>

<script>
	import { getAllGoodsList } from "@/common/api.js"
	import GoodsItem from '@/components/GoodsItem/GoodsItem'
	
	export default {
		data() {
			return {
				wishGoodsList: []
			}
		},
		components: {
			GoodsItem
		},
		methods: {
			goPublishWish() {
				uni.navigateTo({
					url: "/pages/wishList/wishList"
				})
			},
			// 轮播图点击事件
			swiperClick(index) {
				console.log("swiperClick():", index);
			},
			scrolltolower() {
				console.log("到达底部");
			},
			goSearch() {
				uni.navigateTo({
					url: "/pages/search/search"
				})
			},
			//轮播图获取
			getSwiperImg() {
				this.swiperImgArray = []
				this.$myRequest({
					url: '/system/banner/list',
					data: {
						parentId: 1
					},
					methods: 'GET'
				}).then(res => {
					// console.log(res)
					if (res.code == 200) {
						res.rows.forEach(e => {
							this.swiperImgArray.push(e.url)
						})
					}
				})
			}, 
			async initWishGoodsList() {
				const { rows } = await getAllGoodsList({
					classificationId: this.classificationId,
					status: 1
				});
				console.log(rows);
				this.wishGoodsList = rows;
			}
		},
		onLoad(option) {
			this.classificationId = JSON.parse(decodeURIComponent(option.classificationId));
			console.log(this.classificationId);
			this.initWishGoodsList();
			this.getSwiperImg();
		},
		onReady() {
			uni.setNavigationBarTitle({ title: this.$t("lookShinee.title")});
		},
	}
</script>

<style>
	page {
		background-color: #FBFBFB;
	}
</style>
<style lang="scss" scoped>
	.search-view {
		padding: 14rpx 22rpx;
		background-color: #fff;
	}

	.goods-list {
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-wrap: wrap;
		padding: 24rpx 40rpx;
		box-sizing: border-box;
		margin-bottom: 120rpx;
	}
</style>
